package com.zhiyu.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.zhiyu.api.ReturnResult;
import com.zhiyu.service.webApi.ISysUserService;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("api/sysUser")
public class SysUserController {

    @Reference(version = "1.0.0")
    ISysUserService iSysUserService;

    /**
     * 获取所有未冻结的系统用户信息列表
     * @param param
     * @return
     */
    @RequestMapping(value = "/getAllUnfrozenSysUserList",method = RequestMethod.POST)
    public ReturnResult getAllUnfrozenSysUserList(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.getAllUnfrozenSysUserList(param);
        return returnResult;
    }

    /**
     * 根据查询条件查询系统用户信息列表
     * @param param
     * @return
     */
    @RequestMapping(value = "/getSysUserList",method = RequestMethod.POST)
    public ReturnResult getSysUserList(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.getSysUserList(param);
        return returnResult;
    }

    /**
     * 根据token查询用户
     * @param param
     * @return
     */
    @RequestMapping(value = "/getSysUserByToken",method = RequestMethod.POST)
    public ReturnResult getSysUserByToken(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.getSysUserByToken(param);
        return returnResult;
    }

    /**
     * 根据id查询系统用户
     * @param param
     * @return
     */
    @RequestMapping(value = "/getSysUserById",method = RequestMethod.POST)
    public ReturnResult getSysUserById(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.getSysUserById(param);
        return returnResult;
    }

    /**
     * 校验登录账号是否已存在
     * @param param
     * @return
     */
    @RequestMapping(value = "/checkIsExistSysUserByUserName",method = RequestMethod.POST)
    public ReturnResult checkIsExistSysUserByUserName(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.checkIsExistSysUserByUserName(param);
        return returnResult;
    }

    /**
     * 新增系统用户
     * @param param
     * @return
     */
    @RequestMapping(value = "/addSysUser",method = RequestMethod.POST)
    public ReturnResult addSysUser(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.addSysUser(param);
        return returnResult;
    }

    /**
     * 修改系统用户信息
     * @param param
     * @return
     */
    @RequestMapping(value = "/updateSysUser",method = RequestMethod.POST)
    public ReturnResult updateSysUser(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.updateSysUser(param);
        return returnResult;
    }

    /**
     * 修改密码
     * @param param
     * @return
     */
    @RequestMapping(value = "/updatePassword",method = RequestMethod.POST)
    public ReturnResult updatePassword(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.updatePassword(param);
        return returnResult;
    }

    /**
     * 重置密码
     * @param param
     * @return
     */
    @RequestMapping(value = "/resetPassword",method = RequestMethod.POST)
    public ReturnResult resetPassword(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.resetPassword(param);
        return returnResult;
    }

    /**
     * 删除系统用户
     * @param param
     * @return
     */
    @RequestMapping(value = "/deleteSysUser",method = RequestMethod.POST)
    public ReturnResult deleteSysUser(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.deleteSysUser(param);
        return returnResult;
    }

    /**
     * 冻结、解冻系统用户
     * @param param
     * @return
     */
    @RequestMapping(value = "/frozenSysUser",method = RequestMethod.POST)
    public ReturnResult frozenSysUser(@RequestBody Map<String, Object> param){
        ReturnResult returnResult = iSysUserService.frozenSysUser(param);
        return returnResult;
    }

}
